package org.dreamwork.jasmine2.restful.client.gui.util;

import javax.swing.filechooser.FileFilter;
import java.io.File;

/**
 * Created by IntelliJ IDEA.
 * User: seth.yang
 * Date: 2014/12/10
 * Time: 2:21
 */
public class Filters {
    public static final FileFilter PEM = new FileFilter () {
        @Override
        public boolean accept (File file) {
            if (file.isDirectory ())
                return true;
            String ext = file.getName ().toLowerCase ();
            return ext.endsWith (".pem") || ext.endsWith (".key");
        }

        @Override
        public String getDescription () {
            return "Public Key Files (*.pem;*.key)";
        }
    }, X509 = new FileFilter () {
        @Override
        public boolean accept (File file) {
            if (file.isDirectory ()) return true;
            String name = file.getName ().toLowerCase ();
            return name.endsWith (".x509");
        }

        @Override
        public String getDescription () {
            return "X509 Public Key Files (*.x509)";
        }
    }, CERTIFICATE = new FileFilter () {
        @Override
        public boolean accept (File file) {
            if (file.isDirectory ()) return true;
            String name = file.getName ().toLowerCase ();
            return name.endsWith (".cert") || name.endsWith (".cer");
        }

        @Override
        public String getDescription () {
            return "X509 Certificate Files (*.cer;*.cert)";
        }
    }, SAVED_PARAMETER = new FileFilter () {
        @Override
        public boolean accept (File file) {
            return file.isDirectory () || file.getName ().endsWith (".sdp");
        }

        @Override
        public String getDescription () {
            return "Saved Parameter (*.sdp)";
        }
    };
}
